package aad.storyboard.model;

import java.util.ArrayList;

import aad.storyboard.controller.GUIComposer;
import aad.storyboard.view.GraphicView;
import android.graphics.Paint;

public class BlinkAnimation extends Animation{
	
    private ArrayList <GraphicalObject> objects;
	int counter=0;
	int counterold=0;
    
   private static int foregrndalpha = 255;   

	public BlinkAnimation(int duration, int t, ArrayList <GraphicalObject> objects) {
		super(duration, t);	
		this.objects=objects;
		
	}

	@Override
	public void animate() {
		GraphicView g=(GraphicView) GUIComposer.getInstance().getGraphicalView();
		g.setBlinkObjects(objects);
		
		if (counterold+15==counter){
			counterold=counter;
			System.out.println("Check"+counter+" "+counterold);
		if(foregrndalpha > 0)  
    	{  
    		foregrndalpha = 0;  
    		
    		for (GraphicalObject c: this.objects)
    		{
        	 Paint paint=c.getPaint();
        	 paint.setAlpha(foregrndalpha);
    		}
    			      	      
    	    
    	}  
    		       
		else 
		{    	 
    		foregrndalpha = 255;          
    		
    		for (GraphicalObject c: this.objects)
    		{
        	 Paint paint=c.getPaint();
        	 paint.setAlpha(foregrndalpha);
    		}			
		}
		}
		
		counter++;
	}

	@Override
	public void adjustParameters() {
				
	}

}
